<template>
  <div>
    文章标题：<input type="text" v-model="title" />
    <br />
    是否公开:<input type="checkbox" v-model="isOpen" />
    <br />
    文章内容：<textarea v-model="content"></textarea><br />
    <el-button type="primary" @click="publish">发布</el-button>
  </div>
</template>

<script setup lang="ts">
import http from "../utils/http.js";
import { ref } from "vue";
let title = ref("");
let isOpen = ref(false);
let content = ref("");
function publish() {
  http({
    method: "post",
    url: "/posts",
    data: {
      title: title.value,
      content: content.value,
      status: isOpen.value,
    },
  }).then((res: any) => {
    console.log(res);
  });
}
</script>

<style>
textarea {
  width: 200px;
  height: 100px;
}
.el-button {
  margin-top: 20px;
}
div {
  color: black;
}
</style>
